package com.yunze.apiCommon.upstreamAPI.YunDa.Inquire;


import com.yunze.apiCommon.upstreamAPI.DianXinCMP5G.SignUtil;
import com.yunze.apiCommon.upstreamAPI.YunDa.YunDa_Api;
import com.yunze.apiCommon.utils.HttpUtil;
import com.yunze.apiCommon.utils.UrlUtil;

import java.util.HashMap;
import java.util.Map;

/**
 * 查询类接口
 */
public  class Query_YunDa extends YunDa_Api {

    public static void main(String[] args) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("cd_username", "https://api.xiyantec.com");
        map.put("cd_pwd","6489664f5b0a2754fc2fb9f2");
        map.put("cd_key","A0046E67EA5744678AFCEF6B9A81BA9C");

        Query_YunDa Qy = new Query_YunDa(map);
        for (int i = 0; i <1 ; i++) {
            System.out.println(Qy.batchGetSimLifecycle("898607B91923C0218000"));//
        }

    }


    public Query_YunDa(Map<String, Object> init_map) {
        super(init_map);
    }


    /**
     * 获取单个卡 信息
     * @param iccid
     * @param
     * @return
     */
    public static String batchPackageQuery(String iccid) {
        String method = "/v1/BatchPackageQuery";//
        return batchQueryCommon(iccid,method);
    }


    public static String batchGetSimStatus(String iccid) {
        String method = "/v1/BatchGetSimStatus";//
        return batchQueryCommon(iccid,method);
    }

    public static String batchGetCurrentMonthGprs(String iccid) {
        String method = "/v1/BatchGetCurrentMonthGprs";//
        return batchQueryCommon(iccid,method);
    }

    public static String batchSimOnlineQuery(String iccid) {
        String method = "/v1/BatchSimOnlineQuery";//
        return batchQueryCommon(iccid,method);
    }


    public static String batchGetSimLifecycle(String iccid) {
        String method = "/v1/BatchGetSimLifecycle";//
        return batchQueryCommon(iccid,method);
    }

    public static String batchQueryCommon(String iccid,String method ) {
        String Rstr = null;
        try {
            String timestamp = ""+System.currentTimeMillis() ;
            Map<String, Object> params = new HashMap<>();
            params.put("iccids",iccid);
            params.put("appKey",appKey);
            params.put("timestamp",timestamp);
            String sign = getSign(params);
            params.put("sign",sign);
            String url = server_Ip+method ;
            String param_url = UrlUtil.getUrl(url, params);
            Map<String,String> headers = new HashMap<>();
            headers.put("Content-Type", "application/x-www-form-urlencoded");
            Rstr = HttpUtil.get(param_url,headers);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return Rstr;
    }







}
